Page({
    data: {
        address:'',
        address_name:'',
        longitude: '',
        latitude: ''
    },
    // 选择地址功能
    chooseLocation() {
        swan.authorize({
            scope: 'scope.userLocation',
            success: res => {
                console.log('authorize', res);
            },
            fail: err => {
                swan.openSetting({});
            }
        });
        swan.chooseLocation({
            success: res => {
                console.log('chooseLocation success', res);
                let longitude = res.longitude;
                let latitude = res.latitude;
                this.setData({
                    address_name: res.name,
                    address: res.address,
                    longitude: longitude,
                    latitude: latitude
                });
            },
            fail: err => {
                console.log('错误码：' + err.errCode);
                console.log('错误信息：' + err.errMsg);
            }
        });
    }
});